#include <iostream>
#include <opencv2/opencv.hpp>

using namespace cv;
using namespace std;

/**
 * 颜色空间转换
 */
int main(){
    cv::Mat image = imread("../resource/wukong.jpg");
    if(image.empty()){
        cout << "image is empty" << endl;
        return -1;
    }

    cv::Mat hsvImage,grayImage;
    cv::cvtColor(image,hsvImage,cv::COLOR_BGR2HSV);
    cv::cvtColor(image,grayImage,cv::COLOR_BGR2GRAY);

    cv::imshow("image",image);
    cv::imshow("hsvImage",hsvImage);
    cv::imshow("grayImage",grayImage);

    cv::imwrite("../resource/wukong_hsv.jpg",hsvImage);
    cv::imwrite("../resource/wukong_gray.jpg",grayImage);
    cv::waitKey(0);
    cv::destroyAllWindows();
    system("pause");

    return 0;
}